import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import VueRouter from 'vue-router'
import './plugins/element.js'
import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/common.css'
import "./router/permission"
import "./utils/eventbus"
import * as echarts from "echarts";
import jsCookie from 'js-cookie'
import Echarts from "./plugins/echarts"
// import './assets/css/main.css'

Vue.prototype.$echarts = echarts
Vue.config.productionTip = false;
Vue.config.productionTip = false

Vue.use(Echarts)


if (localStorage.getItem("tunnel")) {
  store.commit("loginModule/updateToken", jsCookie.get("username"));
  store.commit("loginModule/updateUsername", jsCookie.get("token"));
}

const RouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return RouterPush.call(this, to).catch(err => err)
}
const RouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (to) {
  return RouterReplace.call(this, to).catch(err => err)
}

Vue.prototype.pxzoom = function rezoom() {
  let zoom = 1
  if (window.screen.width > 3800) {
    zoom = 2
  } else if (window.screen.width > 3000) {
    zoom = 1.4
  } else if (window.screen.width > 2500) {
    zoom = 1.26
  } else if (window.screen.width > 2000) {
    zoom = 1.1
  }else if (window.screen.width > 1800) {
    zoom = 1.05
  } else if (window.screen.width > 1600) {
    zoom = 1
  }else if (window.screen.width > 1450) {
    zoom = 0.78
  } else if (window.screen.width > 1300) {
    zoom = 0.7
  }
  return { px: window.screen.width, zoom }
}


new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
